<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;

use Illuminate\Http\Resqonse;

//use DB;

class PhotoController extends Controller
{
    //
    public function index()
    {
    	return "1111111";
    }

    //查询数据
    //"\"因为是命名空间所以要加"\"或者在上面写上 "use :DB;";
    public function getlist()
    {
    	$data = \DB::table("news")->get();
    	dd($data);
    }

    //文件上传操作
    public function doUpload(Request $request)
    {
        //判断是否有上传
        if($request->hasFile("upfile")){
            //获取上传信息
            $file = $request->file("upfile");
            //确认上传的文件是否成功
            if($file->isValid()){
                //$picname = $file->getClientOriginalName(); //获取上传原文件名
                $ext = $file->getClientOriginalExtension(); //获取上传文件名的后缀名
                //执行移动上传文件
                $filename = time().rand(1000,9999).".".$ext;
                $file->move("./upload/",$filename);
                                
                return response($filename); //输出
                exit();
            }
        }
    }


    public function response()
    {
        //$content="Hello Laravel!";
        //$status = 403;
        //$value = "text/html";
        //return (new Response($content,$status))->header('Content-Type',$value);
        //return $data->header("Content-Type"$value);
        //return Response("aa",200)->header("lamp","186");
        //return Response("aa",200)->cookie("典韦","妞妞");
        //json响应是不要加返回状态信息
        //return Response()->json(["name"=>"hello"]);
        //跳转信息('home/dashbiard'要跳转的页面)
        return redirect('home/dashbiard');
    }
}
